﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Tyloo.ViewModels;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace Tyloo
{
    public partial class FacebookPage : PhoneApplicationPage
    {
        string appId = "313548295424392";
        string description = "Tyloo Mobile App";
        string picture = "http://profile.ak.fbcdn.net/hprofile-ak-prn1/c23.23.290.290/s160x160/73070_217540238381170_1463277912_n.png";
        string name = "Tyloo";
        string caption = "Tyloo";
        string link = "http://www.tyloo.com";
        string redirect = "http://www.facebook.com";
        public FacebookPage()
        {
            Initialize();
        }
        private void Initialize()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string strItemIndex;
            string site = "";
            ItemViewModel item = new ItemViewModel();
            if (NavigationContext.QueryString.TryGetValue("global", out strItemIndex))
            {
                site = "https://www.facebook.com/dialog/feed?app_id=" + appId + "&description=HIZY Mobile Application&name=HIZY&caption=HIZY&redirect_uri=" + redirect + "&link=http://facebook.com";
            }
            else
            {
                if (PhoneApplicationService.Current.State.ContainsKey("Share"))
                {
                    item = (ItemViewModel)PhoneApplicationService.Current.State["Share"];
                }
                site = "https://www.facebook.com/dialog/feed?app_id=" + appId + "&description=" + item.Description+ "&name=HIZY&picture=" + item.Image+ "&caption=" + item.Title+ "&redirect_uri=" + redirect + "&link=" + item.Url;
            }
            webBrowser.Navigate(new Uri(site, UriKind.Absolute));
        }

        private void appBarChange(object sender, ApplicationBarStateChangedEventArgs e)
        {

        }

        private void homeClick(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/Home.xaml?", UriKind.Relative));
        }
        private void aboutClick(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/About.xaml?", UriKind.Relative));
        }
    }
}